home *** CD-ROM | disk | FTP | other *** search
- <HTML>
- <HEAD>
- <TITLE>Bringing it all together</TITLE>
- </HEAD>
-
- <SCRIPT LANGUAGE="JavaScript">
- var L=new layerTool();
- function layerTool()
- {
- if (navigator.appName=="Netscape")
- this.layerProp=navProp;
- else
- this.layerProp=exProp;
- }
- function exProp()
- {
- return document.all[arguments[arguments.length-1]].style;
- }
- function navProp()
- {
- retVal="";
- for (var x=0;x<arguments.length;x++)
- {
- retVal+="document.layers[\'"+arguments[x]+"\']";
- if (x!=arguments.length-1)
- retVal+=".";
- }
- return eval(retVal);
- }
- function Point(X,Y)
- {
- this.x=X;
- this.y=Y;
- }
- function rect(X1,Y1,X2,Y2)
- {
- this.left=X1;
- this.top=Y1;
- this.right=X2;
- this.bottom=Y2;
- }
- function foster(child,ancestor)
- {
- for (x in ancestor)
- {
- if (!(child [x.toString()]))
- child [x.toString()]=ancestor[x];
- }
- }
- function random (limit)
- {
- return (Math.round(((Math.random())*1000))%limit);
- }
-
- function layerObject(layerID,pos,vel,z,bounds,bounce)
- {
- // properties
- this.layerID=layerID;
- this.position=pos;
- this.velocity=vel;
- this.boundsRect=bounds;
- this.depth=z;
- this.bounce=bounce;
- this.visibility="visible";
- this.isGoing=false;
- this.active=true;
- // methods
- this.show=showLayer;
- this.setZorder=setZorder;
- this.hide=hideLayer;
- this.setPosition=setPosition;
- this.draw=drawLayer;
- this.update=updateLayer;
- this.journey=journey;
- this.courseCorrect=courseCorrect;
- this.show();
- }
-
- function setZorder(z)
- {
- this.depth=z;
- }
- function showLayer()
- {
- L.layerProp(this.layerID).visibility="visible";
- }
- function hideLayer()
- {
- L.layerProp(this.layerID).visibility="hidden";
- }
- function drawLayer()
- {
- L.layerProp(this.layerID).zIndex=this.depth;
- L.layerProp(this.layerID).left=(this.position).x;
- L.layerProp(this.layerID).top=(this.position).y;
- }
- function setPosition(pos)
- {
- this.position=pos;
- }
- function journey(target,jumps)
- {
- this.leaps=jumps;//number of jumps
- this.target=target;
- this.isGoing=true;
- this.active=true;
- }
- function courseCorrect()
- {
- var xDist=(this.target.x-this.position.x);
- var yDist=(this.target.y-this.position.y);
- if (this.leaps>1)
- {
- this.leaps--;
- this.velocity.x=Math.round( xDist/(this.leaps) ) ;
- this.velocity.y=Math.round( yDist/(this.leaps) );
- }
- else
- {
- this.isGoing=false;
- this.velocity=new Point(0,0);
- }
- }
- function updateLayer()
- {
- if (this.isGoing)
- this.courseCorrect();
- if (this.velocity.x==0 && this.velocity.y==0)
- this.active=false;
- else
- this.active=true;
- var newPos=new Point(this.position.x+this.velocity.x,
- this.position.y+this.velocity.y);
- if (this.bounce && ! this.isGoing)
- {
- if (newPos.x>this.boundsRect.right || newPos.x<this.boundsRect.left)
- {
- this.velocity.x = this.velocity.x*-1;
- newPos.x += (this.velocity.x *2);
- }
- if (newPos.y>this.boundsRect.bottom || newPos.y<this.boundsRect.top)
- {
- this.velocity.y=this.velocity.y*-1;
- newPos.y+= (this.velocity.y *2);
- }
- }
- this.setPosition(newPos);
- }
-
- function noteObject(layerID,pos,z)
- {
- this.ancestor=new layerObject(layerID,
- pos,
- new Point(0,0),
- z,
- new rect(0,0,1000,1000),
- false);
- foster(this,this.ancestor);
- this.defaultDepth=z;
- this.home=pos;
- }
-
- function noteManager()
- {
- this.LayerList=new Array();
- this.add=noteAdd;
- this.select=noteSelect;
- }
-
- function noteAdd(LayerObj)
- {
- this.LayerList[this.LayerList.length]=LayerObj;
- this.zone=new Point(LayerObj.position.x+160,LayerObj.position.y);
- }
-
- function noteSelect(LayerName)
- {
- for (var x=0;x<this.LayerList.length;x++)
- {
- if (this.LayerList[x].layerID==LayerName)
- {
- if (this.LayerList[x].depth==100)
- {
- this.LayerList[x].setZorder(this.LayerList[x].defaultDepth);
- this.LayerList[x].journey(this.LayerList[x].home,6);
- }
- else
- {
- this.LayerList[x].setZorder(100);
- this.LayerList[x].journey(this.zone,6);
- }
- }
- else
- {
- this.LayerList[x].setZorder(this.LayerList[x].defaultDepth);
- this.LayerList[x].journey(this.LayerList[x].home,6);
- }
- this.LayerList[x].draw();
- }
- }
-
- function layerManager()
- {
- this.update=managerUpdate;
- this.add=managerAdd;
- this.draw=managerDraw;
- this.layerList=new Array();
- }
- function managerAdd(l)
- {
- this.layerList[this.layerList.length]=l;
- l.draw();
- l.show();
- }
- function managerUpdate()
- {
- for (x=0;x<this.layerList.length;x++)
- {
- if (this.layerList[x].active)
- this.layerList[x].update();
- }
- }
- function managerDraw()
- {
- for (x=0;x<this.layerList.length;x++)
- {
- if (this.layerList[x].active)
- this.layerList[x].draw();
- }
- }
-
- p=new Array();
- p[0]=new Area(25,30,125,75,"http://www.corrosive.co.uk/");
- p[1]=new Area(5,125,130,175,"http://www.corrosive.co.uk/");
- p[2]=new Area(115,100,225,126,"http://www.corrosive.co.uk/");
-
- m=new map("m","container","topLayer",p);
- function Area(X1,Y1,X2,Y2,url)
- {
- this.left=X1;
- this.top=Y1;
- this.right=X2;
- this.bottom=Y2;
- this.url=url;
- }
-
- function map(name,container,top,areas)
- {
- this.name=name;
- this.top=top;
- this.container=container;
- this.areas=areas;
- this.writeMap=writeMap;
- this. highlight=highlight;
- this.reset=reset;
- this.timeout=null;
- }
- function writeMap (mapName)
- {
- document.write("<map name="+mapName+">");
- for (x=0;x<this.areas.length;x++)
- {
- document.write("<area shape=\"RECT\" href='"+this.areas[x].url+"'
- onMouseOver='"+this.name+".highlight("+x+")' ");
- document.write("onMouseOut='"+this.name+".reset()' ");
- document.write("COORDS=\""+this.areas[x].left+","+this.areas[x].top+"
- "+this.areas[x].right+","+this.areas[x].bottom+"\">");
- }
- document.write("</map>");
- }
- function highlight(num)
- {
- clearTimeout(this.timeout);
- this.timeout=setTimeout(this.name+".reset()",5000);
- L.layerProp(this.container,this.top).visibility="visible";
- L.layerProp(this.container,this.top).clip.top=this.areas[num].top;
- L.layerProp(this.container,this.top).clip.left=this.areas[num].left;
- L.layerProp(this.container,this.top).clip.bottom=this.areas[num].bottom;
- L.layerProp(this.container,this.top).clip.right=this.areas[num].right;
- }
- function reset()
- {
- L.layerProp(this.container,this.top).visibility="hidden";
- }
-
- function init()
- {
- layerMan=new layerManager();
- noteMan=new noteManager();
- var yPos=30;
- for (var x=1;x<=5;x++)
- {
- note=new noteObject("note"+x,new Point(10,yPos),x);
- layerMan.add(note);
- noteMan.add(note);
- yPos+=30;
- }
- var xPos=200;
- for (var y=1;y<=3;y++)
- {
- temp=new layerObject(
- "heading"+y,
- new Point (xPos,300),
- new Point (random(30)-15,random(30)-15),
- 200,
- new rect(180,30,500,400),
- true
- )
- layerMan.add(temp);
- xPos+=150;
- }
- cycle();
- }
- function cycle()
- {
- layerMan.update();
- layerMan.draw();
- setTimeout("cycle()",20);
- }
- </SCRIPT>
-
- <STYLE TYPE="text/css">
- .shuffleClass{
- POSITION: absolute;
- WIDTH: 150px;
- VISIBILITY: hidden;
- }
- .headings{
- POSITION:absolute;
- FONT-WEIGHT:100;
- FONT-FAMILY:sans-serif;
- COLOR:#0066cc;
- FONT-SIZE:24pt;
- VISIBILITY:hidden;
- }
- .maps{
- POSITION:absolute;
- }
- #container{
- POSITION:absolute;
- TOP: 130;
- LEFT:250;
- VISIBILITY: visible;
- }
- #topLayer{
- VISIBILITY:hidden;
- }
- ink, A:visited, A:active{
- COLOR:#0D20AE;
- FONT-WEIGHT:bold;
- FONT-FAMILY: sans-serif;
- TEXT-DECORATION: none
- }
- </STYLE>
-
- <BODY BGCOLOR="#ffffff" onLoad="init()">
- <SCRIPT>
- m.writeMap("myMap");
- </SCRIPT>
- <DIV ID="note1" CLASS="shuffleClass">
- <TABLE HEIGHT=200 WIDTH=150 BGCOLOR=#CBD5FF CELLPADDING=10 BORDER=1>
- <TR><TD VALIGN=TOP>
- <A HREF="JavaScript:noteMan.select('note1');">About Us</A>
- <P>
- links and information
- </P>
- </TD></TR>
- </TABLE>
- </DIV>
-
- <DIV ID="note2" CLASS="shuffleClass">
- <TABLE HEIGHT=200 WIDTH=150 BGCOLOR=#CBD5FF CELLPADDING=10 BORDER=1>
- <TR><TD VALIGN=TOP>
- <A HREF="JavaScript:noteMan.select('note2');">Clients</A>
- <P>
- links and information
- </P>
- </TD></TR>
- </TABLE>
- </DIV>
-
- <DIV ID="note3" CLASS="shuffleClass">
- <TABLE HEIGHT=200 WIDTH=150 BGCOLOR=#CBD5FF CELLPADDING=10 BORDER=1>
- <TR><TD VALIGN=TOP>
- <A HREF="JavaScript:noteMan.select('note3');">Freebies</A>
- <P>
- links and information
- </P>
- </TD></TR>
- </TABLE>
- </DIV>
-
- <DIV ID="note4" CLASS="shuffleClass">
- <TABLE HEIGHT=200 WIDTH=150 BGCOLOR=#CBD5FF CELLPADDING=10 BORDER=1>
- <TR><TD VALIGN=TOP>
- <A HREF="JavaScript:noteMan.select('note4');">Links</A>
- <P>
- links and information
- </P>
- </TD></TR>
- </TABLE>
- </DIV>
-
- <DIV ID="note5" CLASS="shuffleClass">
- <TABLE HEIGHT=200 WIDTH=150 BGCOLOR=#CBD5FF CELLPADDING=10 BORDER=1>
- <TR><TD VALIGN=TOP>
- <A HREF="JavaScript:noteMan.select('note5');">Welcome</A>
- <P>
- links and information
- </P>
- </TD></TR>
- </TABLE>
- </DIV>
-
- <DIV ID="container">
- <DIV ID="bottomLayer" CLASS="maps">
- <IMG SRC="res/apple1.gif" USEMAP="#myMap" BORDER=0>
- </DIV>
- <DIV ID="topLayer" CLASS="maps">
- <IMG NAME=TEST SRC="res/apple2.gif" USEMAP="#myMap" BORDER=0>
- </DIV>
- </DIV>
-
- <DIV ID="heading1" CLASS="headings">
- Dynamic
- </DIV>
- <DIV ID="heading2" CLASS="headings">
- Web
- </DIV>
- <DIV ID="heading3" CLASS="headings">
- Design
- </DIV>
- </BODY>
- </HTML>
-